<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of detalle_factura
 *
 * @author jorge-luis
 */
class detalle_factura extends CI_Model {

    public $descripcion;
    public $cantidad;
    public $pvp;
    public $total;
    public $servicio_id;

    function __construct() {
        parent::__construct();
    }

    function calcula_total($cantidad, $pvp) {
        $valor = $cantidad * $pvp;
        return $valor;
    }

    function buscarByFactura($factura_Id) {
        $this->db->select('d.*');
        $this->db->from('detalle_factura as d');
        $this->db->join('factura f', 'd.factura_id = f.id');
        $this->db->where('f.id', $factura_Id);
        $lista = $this->db->get();
        if ($lista->num_rows() > 0) {
            return $lista->result_array();
        } else {
            return null;
        }
    }

    function grabar($datos) {
        $this->db->insert('detalle_factura', $datos);
        return $this->db->insert_id();
    }

}
